#ifndef STEP_MOTOR_USART_H
#define STEP_MOTOR_USART_H

#include "stm32f4xx.h"
#include "main.h"
#include "usart.h"
#include "motor.h"




#define  	STEP_NVIC    0


#define 	STEP_END_BYTE 			0x6b
#define 	STEP_RX_BUF_NUM 		12u             //6*2

#define     PITCH_FRAME_IDENTI    	0x01            //
#define     YAW_FRAME_IDENTI        0x02

#define     TIME_BETWEEN_TWO_SEND   0.01f           //100HZ

#define MOTOR_RAD_TO_REAL_RAD 0.28125f
#define Motor_Ecd_to_Rad 0.000095873799242852f

typedef  struct
{
	fp32 relative_angle;
	fp32 motor_gyro;
} Real_Data;

typedef struct
{
    int32_t   ecd;            //转子机械角度
    fp32 	  speed_rpm;      //转子转速
    int16_t   given_current;  //实际转矩电流(此处为PWM)
    int32_t   last_ecd;       //上次转子机械角度
//	fp32 	relative_angle;    //rad
//	fp32 	motor_gyro;        //rad/s
	const Real_Data* real_one;
} motor_measure_t;


typedef struct
{
	fp32 pitch;                     //pitch角度  
	fp32 gyro_pitch;                //pitch角速度
	fp32 yaw;                    	//yaw角度  
	fp32 gyro_yaw;       			//yaw角速度 
	              
} motor_data_msg;





void step_usart_init(void);
const motor_measure_t *get_pitch_data_point(void);
const motor_measure_t *get_yaw_data_point(void);

void get_pitch_data(void);
void get_yaw_data(void);
void set_pitch_vice(char dir, int16_t vice);
void set_yaw_vice(char dir, int16_t vice);


#endif
